[
  {
    "name": "addCustomerInfo",
    "body": "mutation addCustomerInfo($customerInput: _CreateCustomerInput!) {\n  packet {\n    updateOrCreateCustomer(input: $customerInput) {\n      returning {\n        ...CustomerAttributes\n      }\n    }\n  }\n}\n    fragment CustomerAttributes on _E_Customer {\n  id\n  __typename\n  data {\n    firstName\n    lastName\n  }\n  defaultDeliveryAddress {\n    ...AddressAttributes\n  }\n}\n    fragment AddressAttributes on _G_DeliveryAddress {\n  countryIso\n  regionIso\n  city\n  street\n  flatNumber\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "${customerInput.id} == ${jwt:email}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only user can define his own personal data"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "customerInput",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "addGoodTypeInfo",
    "body": "mutation addGoodTypeInfo($goodTypeInput: _CreateGoodTypeInput!) {\n  packet {\n    updateOrCreateGoodType(input: $goodTypeInput) {\n      returning {\n        ...GoodTypeAttributes\n      }\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "'manager' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only manager can create/update good type info"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "goodTypeInput",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "addOrderDetail",
    "body": "mutation addOrderDetail($customerId: String!, $goodTypeId: String!, $deliveryAddress: _DeliveryAddressInput!) {\n  packet {\n    updateOrCreateOrder(\n      input: {openOrderFlag: $customerId, customer: {entityId: $customerId}, deliveryAddress: $deliveryAddress}\n      exist: {byKey: openOrderFlag}\n    ) {\n      returning {\n        ...OrderAttributes\n      }\n    }\n    createOrderDetail(\n      input: {order: \"ref:updateOrCreateOrder\", goodType: {entityId: $goodTypeId}}\n    ) {\n      ...OrderDetailAttributes\n    }\n  }\n}\n    fragment OrderAttributes on _E_Order {\n  id\n  __typename\n  openOrderFlag\n  orderDate\n  comment\n  statusForVendor {\n    code\n  }\n  orderDetailList {\n    elems {\n      ...OrderDetailAttributes\n    }\n  }\n}\n    fragment OrderDetailAttributes on _E_OrderDetail {\n  id\n  __typename\n  goodType {\n    entity {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}\nfragment OrderDetailAttributes on _E_OrderDetail {\n  id\n  __typename\n  goodType {\n    entity {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "${customerId} == ${jwt:email} && 'customer' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only  customer can add detail to his own order"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "customerId",
        "paramAddition": ""
      },
      {
        "paramName": "goodTypeId",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "createPckg",
    "body": "mutation createPckg($vendorId: ID!, $serialNumber: String!, $deliveryAddress: _DeliveryAddressInput!, $orderDetailId: ID!, $orderDetailRef: String!, $orderRef: String!) {\n  p1: packet {\n    createPckg(\n      input: {vendor: $vendorId, serialNumber: $serialNumber, deliveryAddress: $deliveryAddress, orderDetail: {rootEntityId: $orderRef, entityId: $orderDetailRef}}\n    ) {\n      id\n    }\n  }\n  p2: packet {\n    updateOrderDetail(\n      input: {id: $orderDetailId, statusForVendor: {code: \"PACKAGED\"}}\n    ) {\n      id\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "it.$id == ${orderDetailId} && it.statusForVendor.code == 'OPEN' && it.order.statusForVendor.code == 'FIXED' && it.goodType.entity.vendor.entityId == ${jwt:vendor_id}",
        "orderValue": "0",
        "typeName": "OrderDetail",
        "description": "Vendor can create packages only for OPEN order details on his goods only for FIXED orders"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "vendorId",
        "paramAddition": ""
      },
      {
        "paramName": "serialNumber",
        "paramAddition": ""
      },
      {
        "paramName": "deliveryAddress",
        "paramAddition": ""
      },
      {
        "paramName": "orderDetailId",
        "paramAddition": ""
      },
      {
        "paramName": "orderDetailRef",
        "paramAddition": ""
      },
      {
        "paramName": "orderRef",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "deleteOrderDetail",
    "body": "mutation deleteOrderDetail($orderDetailId: ID!) {\n  packet {\n    deleteOrderDetail(id: $orderDetailId)\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "it.$id == ${orderDetailId} && it.order.customer.entityId == ${jwt:email} && it.order.statusForVendor.code == 'DRAFT'",
        "orderValue": "0",
        "typeName": "OrderDetail",
        "description": "Only owner can delete detail of his order AND only when status of this order is DRAFT"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "orderDetailId",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "fixOrder",
    "body": "mutation fixOrder($orderId: ID!) {\n  packet {\n    updateOrder(\n      input: {id: $orderId, openOrderFlag: null, statusForVendor: {code: \"FIXED\"}}\n    ) {\n      ...OrderAttributes\n    }\n  }\n}\n    fragment OrderAttributes on _E_Order {\n  id\n  __typename\n  openOrderFlag\n  orderDate\n  comment\n  statusForVendor {\n    code\n  }\n  orderDetailList {\n    elems {\n      ...OrderDetailAttributes\n    }\n  }\n}\n    fragment OrderDetailAttributes on _E_OrderDetail {\n  id\n  __typename\n  goodType {\n    entity {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "it.$id == ${orderId} && it.customer.entityId == ${jwt:email}",
        "orderValue": "0",
        "typeName": "Order",
        "description": "Only owner can fix his own order"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "orderId",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "getCustomerInfo",
    "body": "query getCustomerInfo($cond: String!) {\n  searchCustomer(cond: $cond) {\n    elems {\n      ...CustomerAttributes\n    }\n  }\n}\n    fragment CustomerAttributes on _E_Customer {\n  id\n  __typename\n  data {\n    firstName\n    lastName\n  }\n  defaultDeliveryAddress {\n    ...AddressAttributes\n  }\n}\n    fragment AddressAttributes on _G_DeliveryAddress {\n  countryIso\n  regionIso\n  city\n  street\n  flatNumber\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "'supervisor' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only supervisor can see customers personal data"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "cond",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "searchAllOrder",
    "body": "query searchAllOrder($cond: String) {\n  searchOrder(cond: $cond, sort: {crit: \"it.customer.entityId\", order: DESC}) {\n    elems {\n      customer {\n        entityId\n      }\n      ...OrderAttributes\n    }\n  }\n}\n    fragment OrderAttributes on _E_Order {\n  id\n  __typename\n  openOrderFlag\n  orderDate\n  comment\n  statusForVendor {\n    code\n  }\n  orderDetailList {\n    elems {\n      ...OrderDetailAttributes\n    }\n  }\n}\n    fragment OrderDetailAttributes on _E_OrderDetail {\n  id\n  __typename\n  goodType {\n    entity {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "'supervisor' $in ${[]:jwt:realm_access.roles} || 'manager' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only manager or supervisor can see all orders"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "cond",
        "paramAddition": "'supervisor' $in ${[]:jwt:realm_access.roles} || ('manager' $in ${[]:jwt:realm_access.roles} && it.statusForVendor.code == 'FIXED' )"
      }
    ]
  },
  {
    "name": "searchGoodType",
    "body": "query searchGoodType {\n  searchGoodType {\n    elems {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": true,
    "disableJwtVerification": false,
    "paramAdditions": [
      {
        "paramName": "",
        "paramAddition": ""
      }
    ]
  },
  {
    "name": "searchOrder",
    "body": "query searchOrder($cond: String) {\n  searchOrder(cond: $cond, sort: {crit: \"it.orderDate\", order: DESC}) {\n    elems {\n      ...OrderAttributes\n    }\n  }\n}\n    fragment OrderAttributes on _E_Order {\n  id\n  __typename\n  openOrderFlag\n  orderDate\n  comment\n  statusForVendor {\n    code\n  }\n  orderDetailList {\n    elems {\n      ...OrderDetailAttributes\n    }\n  }\n}\n    fragment OrderDetailAttributes on _E_OrderDetail {\n  id\n  __typename\n  goodType {\n    entity {\n      ...GoodTypeAttributes\n    }\n  }\n}\n    fragment GoodTypeAttributes on _E_GoodType {\n  id\n  __typename\n  name\n  descr\n  price\n  vendor {\n    entity {\n      id\n      __typename\n      name\n    }\n  }\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": true,
    "checkSelects": [
      {
        "conditionValue": "'customer' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": "Only customer can see his own orders"
      }
    ],
    "paramAdditions": [
      {
        "paramName": "cond",
        "paramAddition": "it.customer.entityId == ${jwt:email}"
      }
    ]
  },
  {
    "name": "searchOrderDetailForVendor",
    "body": "query searchOrderDetailForVendor($cond: String) {\n  searchOrderDetail(cond: $cond) {\n    elems {\n      ...OrderDetailForVendorAttributes\n    }\n  }\n}\n    fragment OrderDetailForVendorAttributes on _E_OrderDetail {\n  id\n  __typename\n  statusForVendor {\n    code\n  }\n  order {\n    id\n    deliveryAddress {\n      ...AddressAttributes\n    }\n  }\n  goodType {\n    entity {\n      id\n      __typename\n      name\n      vendor {\n        entityId\n      }\n    }\n  }\n}\n    fragment AddressAttributes on _G_DeliveryAddress {\n  countryIso\n  regionIso\n  city\n  street\n  flatNumber\n}",
    "allowEmptyChecks": false,
    "disableJwtVerification": false,
    "checkSelects": [
      {
        "conditionValue": "'vendor' $in ${[]:jwt:realm_access.roles}",
        "orderValue": "0",
        "typeName": "",
        "description": ""
      }
    ],
    "paramAdditions": [
      {
        "paramName": "cond",
        "paramAddition": "it.order.statusForVendor.code == 'FIXED' && it.goodType.entity.vendor.entityId == ${jwt:vendor_id} && it.statusForVendor.code == 'OPEN'"
      }
    ]
  }
]